package com.jz.community.moduleshoppingguide.neighbor.presenter;

import com.jz.community.basecomm.mvp.BaseLifeCyclePresent;
import com.jz.community.basecomm.net.rxandroid.OnLoadListener;
import com.jz.community.moduleshoppingguide.neighbor.bean.CircleMessageBean;
import com.jz.community.moduleshoppingguide.neighbor.model.NeighborModel;
import com.jz.community.moduleshoppingguide.neighbor.model.NeighborModelImp;
import com.jz.community.moduleshoppingguide.neighbor.ui.NeighborMainView;

public class NeighborMainPresenter extends BaseLifeCyclePresent<NeighborMainView.View> implements NeighborMainView.Presenter {

    private NeighborMainView.View view;
    private NeighborModel neighborModel;

    public NeighborMainPresenter(NeighborMainView.View view) {
        this.view = view;
        this.neighborModel = new NeighborModelImp(view.getContext());
    }

    @Override
    public void initUserNeighbor() {
        neighborModel.initUserNeighbor(new OnLoadListener<CircleMessageBean>() {
            @Override
            public void onSuccess(CircleMessageBean circleMessageBean) {
                view.isAddCircle(circleMessageBean);

            }

            @Override
            public void onFail(String msg, int code) {
                if (code == 404) {
                    view.noAddCircle();
                } else {
                    view.showError(msg);
                }

            }
        });

    }
}
